<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;


class StoreCouponIssueUser extends Model
{
    use HasFactory;
    use PimpableTrait;

    /**
     *可批量赋值的字段
     */
    public $fillable = [
        'user_id',
        'issue_coupon_id',
    ];

    /**
     * 默认倒序排序
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 可搜索的字段
     */
    public $searchable = [
        'user_id',
        'issue_coupon_id',
    ];

    /**
     * 优惠券前台用户领取可关联的用户
     */
    public function user(){
        return $this->hasMany(User::class,'user_id','id');
    }

    /**
     * 优惠券前台用户领取可关联的优惠劵
     */

    public function issue(){
        return $this->hasMany(StoreCouponIssue::class,'issue_coupon_id','id');
    }

}
